package org.wu.framework.lazy.orm.core.persistence.format;

import java.util.List;

public class FormatFactory {

    private static final List<FormatMapper> formatMappers = List.of(
            new ForEachFormatMapper(),
            new SimpleFormatMapper()
    );

    /**
     * 格式化
     *
     * @param pattern 文件数据
     * @param param   参数
     */
    public static String format(String pattern, Object param) {
        String nextFormat = pattern;
        for (FormatMapper formatMapper : formatMappers) {
            nextFormat = formatMapper.format(nextFormat, param);
        }
        return nextFormat;

    }
}
